package com.ruoyi.car.service.parts.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.car.pojo.TbPartSim;
import com.ruoyi.car.mapper.parts.TbPartSimMapper;
import com.ruoyi.car.service.parts.ITbPartSimService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbPartSimServiceImpl implements ITbPartSimService {
    @Autowired
    private TbPartSimMapper tbPartSimMapper;

    /**
     * sim卡列表查询
     * @param tbPartSim
     * @return
     */
    @Override
    public List<TbPartSim> partSimList(TbPartSim tbPartSim) {
        //取出iccid
        String iccid = tbPartSim.getIccid();
        //取出车牌号码
        String carNumber = tbPartSim.getCarNumber();
        //取出车辆状态
        Integer carStatus = tbPartSim.getCarStatus();
        //取出vin码
        String vin = tbPartSim.getVin();
        //取出sim卡号
        String simNumber = tbPartSim.getSimNumber();
        //取出sim卡状态
        Integer simStatus = tbPartSim.getSimStatus();
        //新建模糊内的对象值
        QueryWrapper<TbPartSim> tbPartSimQueryWrapper = new QueryWrapper<>();
        tbPartSimQueryWrapper.like(iccid != null ,"iccid" ,iccid);
        tbPartSimQueryWrapper.like(carNumber != null, "car_number",carNumber);
        tbPartSimQueryWrapper.like(carStatus != null, "car_status",carStatus);
        tbPartSimQueryWrapper.like(vin != null,"vin" ,vin);
        tbPartSimQueryWrapper.like(simNumber != null, "sim_number",simNumber);
        tbPartSimQueryWrapper.like(simStatus != null, "sim_status",simStatus);
        return tbPartSimMapper.selectList(tbPartSimQueryWrapper);
    }

    /**
     * sim卡添加
     * @param tbPartSim
     */
    @Override
    public void partSimInsert(TbPartSim tbPartSim) {
        this.tbPartSimMapper.insert(tbPartSim);
    }
}
